﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DevComponents.DotNetBar;

namespace Base
{
    public partial class XtraBaseForm : Office2007Form
    {
         public string ConStr = "Provider=Microsoft.Jet.OleDb.4.0;Data Source=" + Application.StartupPath + @"\\DB\Location.mdb";//Access数据库相对路径
        public XtraBaseForm()
        {
            InitializeComponent();
        }

        private void XtraBaseForm_Load(object sender, EventArgs e)
        {

        }

        #region 系统提示框
        public void ShowError(string message)
        {
            MessageBoxEx.Show("" + message + "", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);

            return;
        }
        public void ShowWaring(string message)
        {
            MessageBoxEx.Show("" + message + "", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);

            return;
        }
        public void ShowInformation(string message)
        {
            MessageBoxEx.Show("" + message + "", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

            return;
        }
        #endregion

        /// <summary>
        ///将二维数组 string[,] Fcell里的列标题字段按顺序装载到DataGridView _dv
        /// </summary>
        /// <param name="_dv">类型：DataGridView</param>
        /// <param name="Fcell">类型：string[][]</param>
        public void initDataView2(DataGridView _dv, string[,] Fcell)
        {
            _dv.DataSource = null;
            // _dv.Columns.Clear();不能直接清除所有列，有些列不是后台加载的（比如反选的列）
            _dv.AllowUserToAddRows = false;
            _dv.AllowUserToDeleteRows = false;
            _dv.AllowUserToOrderColumns = true;
            _dv.AllowUserToResizeRows = false;

            for (int i = 0; i < Fcell.GetLength(0); i++)
            {
                //根据数据库的表的列字段进行装载列标题
                if (Fcell[i, 0] != null)
                {
                    DataGridViewColumn _col = new DataGridViewTextBoxColumn();
                    _col.Name = Fcell[i, 0];
                    _col.HeaderText = Fcell[i, 1];
                    _col.ReadOnly = true;
                    _col.DataPropertyName = Fcell[i, 0];

                    _col.SortMode = DataGridViewColumnSortMode.Automatic;
                    _dv.Columns.Add(_col);
                }

            }
            _dv.AutoGenerateColumns = false;  //让它不自己产生多余的列
            _dv.RowsDefaultCellStyle.BackColor = Color.LightGray;//隔行变色
            _dv.AlternatingRowsDefaultCellStyle.BackColor = Color.White;//隔行变色
            _dv.GridColor = Color.SlateGray;
            _dv.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.AllCells;//列显示字段模式
        }




    }
}
